﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OldFramework
{

    public class Monkey : AnimalBase, IWalkableAnimal, INamedAnimal
    {
        public Monkey()
        {
            if (DateTime.Now.Second % 2 == 0)
            {
                _Name = string.Concat(Guid.NewGuid().ToString().Substring(0, 4));
            }
            else
            {
                _Name = $"无名的{EthnicGroupName}";
            }
            Age = Guid.NewGuid().ToByteArray().FirstOrDefault();
        }
        public Monkey(string name)
        {
            _Name = name;
        }


        string _Name = "";
        public override string CategoryName => "灵长类";
        public override string EthnicGroupName => "猿猴";

        public string Name => _Name;

        public override void Move()
        {
            if (Age < 1)
            {
                Console.WriteLine($"{Name} crawl!");
            }
            else
            {
                Console.WriteLine($"{Name} walked or crawl!");
            }
        }

        void IWalkableAnimal.Walk()
        {
            if (Age < 1)
            {
                Console.WriteLine($"{Name} can crawl,but walk!");
            }
            else
            {
                Console.WriteLine($"{Name} walked or crawl!");
            }
        }
        public override void Talk()
        {
            Console.WriteLine($"{Name}:吱吱");
        }

        public override void Talk(AnimalBase animal)
        {
            Console.WriteLine($"{Name}:吱吱吱");
        }

        public override string ToString()
        {
            return $"\"吱吱\",这是{CategoryName}{EthnicGroupName}的{Name}在庆祝它{Age}的生日";
        }
    }
}
